# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=ncdu2
pkgver=2.3
pkgrel=0
pkgdesc="Disk usage analyzer with an ncurses interface"
url="https://dev.yorhel.nl/ncdu"
license="MIT"
arch="x86_64 aarch64" # Limited by zig aport
makedepends="chrpath zig ncurses-dev"
subpackages="$pkgname-doc"
source="https://dev.yorhel.nl/download/ncdu-$pkgver.tar.gz"
builddir="$srcdir/ncdu-$pkgver"
replaces=ncdu

# We may want other than "baseline" for other targets, when enabled by zig
case "$CARCH" in
	aarch64|x86_64) cputarget=baseline ;;
esac

build() {
	zig build -Doptimize=ReleaseSafe -Dpie=true ${cputarget:+-Dcpu="$cputarget"}
}

check() {
	zig build test
}

package() {
	install -Dm755 zig-out/bin/ncdu "$pkgdir"/usr/bin/ncdu
	chrpath -d "$pkgdir"/usr/bin/ncdu

	make install-doc PREFIX="$pkgdir/usr"

	install -Dm644 LICENSES/MIT.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

sha512sums="
283f78761b225883e090c4d0d1325bffc70049477087df3e8d1afcebc3136930c2636b2bba4aa6e43d53626668519c26a1528ba5c75489d3b5924e8974184e47  ncdu-2.3.tar.gz
"
